package com.blast.sspai.activity;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.view.Window;

import com.blast.sspai.R;

/**
 * author : hg
 * email: 530157892@qq.com
 * 15/6/15.
 */

/**
 * 引导界面
 */
public class GuideActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_guide);

        //保存当前版本的引导页已经显示

        //获取清单文件中versionCode 默认为1
        PackageManager manager = getPackageManager();
        int versionCode =1 ;
        try {
            PackageInfo packageInfo = manager.getPackageInfo(getPackageName(), PackageManager.GET_ACTIVITIES);
            versionCode = packageInfo.versionCode;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }

        SharedPreferences sp = getSharedPreferences(getPackageName(),MODE_PRIVATE);
        SharedPreferences.Editor edit = sp.edit();

        //根据版本来进行存储
        edit.putBoolean(getPackageName() +versionCode,true);
        edit.putString("version", "" + versionCode);
        edit.commit();
    }

    public void seeOnClick(View view) {
        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
        finish();
    }
}